#ifndef View_First
#define View_First
#ifdef __GNUG__
#pragma interface
#endif

#include "VObject.h"
#include "Symbol.h"

class SeqCollection;;
class EvtHandler;
class Clipper;
class Document;
class Data;
class Menu;

extern bool gPrinting;

enum ViewFlags {
	eViewNoPrint=   BIT(eVObjLast+1),
	eViewLast   =   eVObjLast + 1
};

enum ViewSizeDet {
	eViewHFit   = BIT(0),
	eViewVFit   = BIT(1),
	eViewDefault= 0
};

class View: public VObject {
protected:
	SeqCollection *clippers;
	EvtHandler *nexthandler;
	Clipper *focus;
public:
	MetaDef(View);

	View(EvtHandler *eh, Rectangle itsExtent, int id= -1);
	~View();

	void SetExtent(Point);
	SeqCollection *GetClipperList()
		{ return clippers; }
	void CheckOpen();
	void Open(bool mode);
	EvtHandler *GetNextHandler();
	void SetNextHandler(EvtHandler *);
	Document *GetDocument();
	Rectangle GetViewedRect();
	void ExtentChanged(VObject *what);

	//---- Drawing ---------------------------------
	void DrawAll(Rectangle, bool);
	void InvalidateRect(Rectangle);

        virtual void ShowInAllClippers(FeedbackFunc, Clipper *vop,
                Command*, const Point &ap, const Point &pp, bool); // obsolete
	virtual void Update();

	//---- Printing ---------------------------------
	virtual Rectangle NextPageBreak(int page, const Rectangle &pr);
	virtual void PrintAdorn(const Rectangle&, int);
	void DoObserve(int i, int c, void *v, Object *op);

	//---- Selection --------------------------------
	virtual void ShowSelection(bool redraw= TRUE, bool show= TRUE);
	void HideSelection(bool redraw= TRUE)
		{ ShowSelection(redraw, FALSE); }
	virtual void ClearSelection(bool redraw= TRUE);

	//---- Scrolling --------------------------------
	void SetContainer(VObject *v);
	void ClearContainer(VObject *v);
	virtual void CalcScrollStep(Point &delta, const Point &relOrigin, const Point &scroll);
	virtual void ConstrainScroll(Point*);
	void RevealRect(Rectangle r, Point e);
	void RevealAlign(Rectangle, VObjAlign al= (VObjAlign)(eVObjHLeft+eVObjVTop));
	void Scroll(int mode, Point scroll, bool redraw= TRUE);

	//---- Clipboard --------------------------------
	virtual Command *PasteData(Data*);
	virtual bool HasSelection();
	virtual bool IsReadOnly();
	bool CanPaste(Data *data);

	//---- Menu related methods ---------------------
	Command *DoMenuCommand(int cmd);
	void DoSetupMenu(Menu*);

	//---- Events -----------------------------------
	Command *Input(Point lp, Token &t, Clipper *cl);
	Command *DoCursorKeyCommand(EvtCursorDir, Token);
	Command *DoFunctionKeyCommand(int, Token);
		
	//---- Inspecting -------------------------------
	void InspectorId(char *buf, int sz);
};

#endif
